package com.string;

import java.util.ArrayList;
import java.util.HashSet;

class StudentHash{
	int id;
	String name;
	StudentHash(int id,String name){
		this.id=id;
		this.name=name;
	}
	public String toString(){
		return id+"\t"+name;
	}
	public boolean equals(Object obj){
		StudentHash sh=(StudentHash)obj;
		return this.id==sh.id && this.name==sh.name;
	}
	public int hashCode(){
		String id1=Integer.toString(id);
		int hash=id1.hashCode();
		hash=hash+name.hashCode();
		return hash;
	}
}

public class DemoString {
	
public static void main(String[] args) {
	//HashSet s=new HashSet();
	ArrayList s=new ArrayList();
	s.add(new StudentHash(101, "deepak"));
	s.add(new StudentHash(101, "deepak"));
	s.add(new StudentHash(102, "amit"));
	for(Object sh:s){
	
	System.out.println(sh);
	}
	//System.out.println(s.hashCode());
	
}
}
